//
//  ViewController.m
//  YaYa
//
//  Created by 张亚 on 2019/1/8.
//  Copyright © 2019年 张亚. All rights reserved.
//

#import "ViewController.h"
#import <FSCalendar.h>

@interface ViewController ()<FSCalendarDelegate,FSCalendarDataSource>

@property (nonatomic, strong) FSCalendar *calendar;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.calendar];

}

- (FSCalendar *)calendar {
    if (!_calendar) {
        //日历控件初始化
        _calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];
        // 设置代理
        _calendar.delegate = self;
        _calendar.dataSource = self;
        _calendar.firstWeekday = 6;     //设置周一为第一天
        _calendar.scrollDirection = FSCalendarScrollDirectionVertical;
        _calendar.appearance.weekdayTextColor = [UIColor blackColor];
        _calendar.appearance.weekdayFont = [UIFont systemFontOfSize:18];
        _calendar.appearance.headerTitleColor = [UIColor darkGrayColor];
        _calendar.appearance.titleDefaultColor = [UIColor darkGrayColor];
        _calendar.appearance.titleFont = [UIFont systemFontOfSize:18];
        //        _calendar.appearance.subtitleDefaultColor = [UIColor greenColor];
        _calendar.appearance.eventDefaultColor = [UIColor lightGrayColor];
        _calendar.appearance.eventSelectionColor = [UIColor lightGrayColor];
        _calendar.appearance.selectionColor = [UIColor redColor];
        _calendar.appearance.headerDateFormat = @"yyyy年MM月";
        _calendar.appearance.todayColor = [UIColor clearColor];
        _calendar.appearance.titleTodayColor = [UIColor lightGrayColor];
        _calendar.appearance.borderRadius = 1.0;  // 设置当前选择是圆形,0.0是正方形
        _calendar.appearance.headerMinimumDissolvedAlpha = 0.0;
        _calendar.backgroundColor = [UIColor whiteColor];
        NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//设置为中文
        _calendar.locale = locale;  // 设置周次是中文显示
        _calendar.headerHeight = 50.0f; // 当不显示头的时候设置
        _calendar.appearance.caseOptions = FSCalendarCaseOptionsWeekdayUsesSingleUpperCase;  // 设置周次为一,二
        [_calendar selectDate:[NSDate date]]; // 设置默认选中日期是今天
        _calendar.placeholderType = FSCalendarPlaceholderTypeFillHeadTail; //月份模式时，只显示当前月份
    }
    return _calendar;
}


@end
